<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - ged.info - test/impl/logged_expectations.ipp</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../index.html">directory</a> - <a href="index.html">test/impl</a> - logged_expectations.ipp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>ged.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2009-06-09</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">78</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">10.3 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">8</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : //  (C) Copyright Gennadiy Rozental 2005-2008.
<span class="lineNum">       2 </span>                : //  Use, modification, and distribution are subject to the
<span class="lineNum">       3 </span>                : //  Boost Software License, ELOG_VER 1.0. (See accompanying file
<span class="lineNum">       4 </span>                : //  http://www.boost.org/LICENSE_1_0.txt)
<span class="lineNum">       5 </span>                : 
<span class="lineNum">       6 </span>                : //  See http://www.boost.org/libs/test for the library home page.
<span class="lineNum">       7 </span>                : //
<span class="lineNum">       8 </span>                : //  File        : $RCSfile$
<span class="lineNum">       9 </span>                : //
<span class="lineNum">      10 </span>                : //  Version     : $Revision: 49312 $
<span class="lineNum">      11 </span>                : //
<span class="lineNum">      12 </span>                : //  Description : Facilities to perform interaction based testng of logged expectations
<span class="lineNum">      13 </span>                : // ***************************************************************************
<span class="lineNum">      14 </span>                : 
<span class="lineNum">      15 </span>                : #ifndef BOOST_TEST_LOGGED_EXPECTATIONS_IPP_120905GER
<span class="lineNum">      16 </span>                : #define BOOST_TEST_LOGGED_EXPECTATIONS_IPP_120905GER
<span class="lineNum">      17 </span>                : 
<span class="lineNum">      18 </span>                : // Boost.Test
<span class="lineNum">      19 </span>                : #include &lt;boost/test/detail/config.hpp&gt;
<span class="lineNum">      20 </span>                : 
<span class="lineNum">      21 </span>                : #if BOOST_TEST_SUPPORT_INTERACTION_TESTING
<span class="lineNum">      22 </span>                : 
<span class="lineNum">      23 </span>                : #include &lt;boost/test/detail/global_typedef.hpp&gt;
<span class="lineNum">      24 </span>                : 
<span class="lineNum">      25 </span>                : #include &lt;boost/test/utils/callback.hpp&gt;
<span class="lineNum">      26 </span>                : #include &lt;boost/test/utils/iterator/token_iterator.hpp&gt;
<span class="lineNum">      27 </span>                : 
<span class="lineNum">      28 </span>                : #include &lt;boost/test/interaction_based.hpp&gt;
<span class="lineNum">      29 </span>                : #include &lt;boost/test/test_tools.hpp&gt;
<span class="lineNum">      30 </span>                : 
<span class="lineNum">      31 </span>                : #include &lt;boost/test/detail/suppress_warnings.hpp&gt;
<span class="lineNum">      32 </span>                : 
<span class="lineNum">      33 </span>                : // Boost
<span class="lineNum">      34 </span>                : #include &lt;boost/lexical_cast.hpp&gt;
<span class="lineNum">      35 </span>                : 
<span class="lineNum">      36 </span>                : // STL
<span class="lineNum">      37 </span>                : #include &lt;fstream&gt;
<span class="lineNum">      38 </span>                : 
<span class="lineNum">      39 </span>                : //____________________________________________________________________________//
<span class="lineNum">      40 </span>                : 
<span class="lineNum">      41 </span>                : namespace boost {
<span class="lineNum">      42 </span>                : 
<span class="lineNum">      43 </span>                : using namespace ::boost::unit_test;
<span class="lineNum">      44 </span>                : 
<span class="lineNum">      45 </span>                : namespace itest {
<span class="lineNum">      46 </span>                : 
<span class="lineNum">      47 </span>                : // ************************************************************************** //
<span class="lineNum">      48 </span>                : // **************    logged expectation test implementation    ************** //
<span class="lineNum">      49 </span>                : // ************************************************************************** //
<span class="lineNum">      50 </span>                : 
<span class="lineNum">      51 </span><span class="lineNoCov">              0 : struct expectations_logger : itest::manager {</span>
<span class="lineNum">      52 </span>                :     // Constructor
<span class="lineNum">      53 </span>                :     expectations_logger( const_string log_file_name, bool test_or_log );
<span class="lineNum">      54 </span>                : 
<span class="lineNum">      55 </span>                :     virtual bool        decision_point( const_string, std::size_t );
<span class="lineNum">      56 </span>                :     virtual unsigned    enter_scope( const_string, std::size_t, const_string scope_name );
<span class="lineNum">      57 </span>                :     virtual void        allocated( const_string, std::size_t, void*, std::size_t s );
<span class="lineNum">      58 </span>                :     virtual void        data_flow( const_string d );
<span class="lineNum">      59 </span>                :     virtual std::string return_value( const_string default_value );
<span class="lineNum">      60 </span>                :     
<span class="lineNum">      61 </span>                : private:
<span class="lineNum">      62 </span>                :     // Data members
<span class="lineNum">      63 </span>                :     bool            m_test_or_log;
<span class="lineNum">      64 </span>                :     std::fstream    m_log_file;
<span class="lineNum">      65 </span>                : };
<span class="lineNum">      66 </span>                : 
<span class="lineNum">      67 </span><span class="lineCov">              2 : literal_string ELOG_VER     = &quot;1.0&quot;;</span>
<span class="lineNum">      68 </span><span class="lineCov">              2 : literal_string CLMN_SEP     = &quot;|&quot;;</span>
<span class="lineNum">      69 </span>                : static const char LINE_SEP  = '\n';
<span class="lineNum">      70 </span>                : 
<span class="lineNum">      71 </span><span class="lineCov">              2 : literal_string FILE_SIG     = &quot;ELOG&quot;;</span>
<span class="lineNum">      72 </span><span class="lineCov">              2 : literal_string SCOPE_SIG    = &quot;SCOPE&quot;;</span>
<span class="lineNum">      73 </span><span class="lineCov">              2 : literal_string ALLOC_SIG    = &quot;ALLOC&quot;;</span>
<span class="lineNum">      74 </span><span class="lineCov">              2 : literal_string DP_SIG       = &quot;SWITCH&quot;;</span>
<span class="lineNum">      75 </span><span class="lineCov">              2 : literal_string DATA_SIG     = &quot;DATA&quot;;</span>
<span class="lineNum">      76 </span><span class="lineCov">              2 : literal_string RETURN_SIG   = &quot;RETURN&quot;;</span>
<span class="lineNum">      77 </span>                : 
<span class="lineNum">      78 </span>                : //____________________________________________________________________________//
<span class="lineNum">      79 </span>                : 
<span class="lineNum">      80 </span><span class="lineNoCov">              0 : expectations_logger::expectations_logger( const_string log_file_name, bool test_or_log )</span>
<span class="lineNum">      81 </span><span class="lineNoCov">              0 : : m_test_or_log( test_or_log )</span>
<span class="lineNum">      82 </span>                : {
<span class="lineNum">      83 </span><span class="lineNoCov">              0 :     BOOST_REQUIRE_MESSAGE( !log_file_name.is_empty(), &quot;Empty expectations log file name&quot; );</span>
<span class="lineNum">      84 </span>                : 
<span class="lineNum">      85 </span><span class="lineNoCov">              0 :     m_log_file.open( log_file_name.begin(), test_or_log ? std::ios::in : std::ios::out );</span>
<span class="lineNum">      86 </span>                : 
<span class="lineNum">      87 </span><span class="lineNoCov">              0 :     BOOST_REQUIRE_MESSAGE( m_log_file.is_open(),</span>
<span class="lineNum">      88 </span>                :                            &quot;Couldn't open expectations log file &quot; &lt;&lt; log_file_name
<span class="lineNum">      89 </span>                :                                 &lt;&lt; &quot; for &quot; &lt;&lt; ( m_test_or_log ? &quot;reading&quot; : &quot;writing&quot;) );
<span class="lineNum">      90 </span>                : 
<span class="lineNum">      91 </span><span class="lineNoCov">              0 :     if( m_test_or_log ) {</span>
<span class="lineNum">      92 </span><span class="lineNoCov">              0 :         std::string line;</span>
<span class="lineNum">      93 </span>                :         
<span class="lineNum">      94 </span><span class="lineNoCov">              0 :         std::getline( m_log_file, line, LINE_SEP );</span>
<span class="lineNum">      95 </span>                :         
<span class="lineNum">      96 </span><span class="lineNoCov">              0 :         const_string cline( line );</span>
<span class="lineNum">      97 </span><span class="lineNoCov">              0 :         string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));</span>
<span class="lineNum">      98 </span>                : 
<span class="lineNum">      99 </span><span class="lineNoCov">              0 :         BOOST_CHECK_EQUAL( *tit, FILE_SIG ); </span>
<span class="lineNum">     100 </span><span class="lineNoCov">              0 :         ++tit;</span>
<span class="lineNum">     101 </span><span class="lineNoCov">              0 :         BOOST_CHECK_EQUAL( *tit, ELOG_VER );</span>
<span class="lineNum">     102 </span>                :     }
<span class="lineNum">     103 </span>                :     else {
<span class="lineNum">     104 </span><span class="lineNoCov">              0 :         m_log_file &lt;&lt; FILE_SIG &lt;&lt; CLMN_SEP &lt;&lt; ELOG_VER &lt;&lt; LINE_SEP;</span>
<span class="lineNum">     105 </span>                :     }
<span class="lineNum">     106 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     107 </span>                : 
<span class="lineNum">     108 </span>                : //____________________________________________________________________________//
<span class="lineNum">     109 </span>                : 
<span class="lineNum">     110 </span>                : bool
<span class="lineNum">     111 </span><span class="lineNoCov">              0 : expectations_logger::decision_point( const_string, std::size_t )</span>
<span class="lineNum">     112 </span>                : {
<span class="lineNum">     113 </span><span class="lineNoCov">              0 :     if( m_test_or_log ) {</span>
<span class="lineNum">     114 </span><span class="lineNoCov">              0 :         std::string line;</span>
<span class="lineNum">     115 </span>                :         
<span class="lineNum">     116 </span><span class="lineNoCov">              0 :         std::getline( m_log_file, line, LINE_SEP );</span>
<span class="lineNum">     117 </span>                :         
<span class="lineNum">     118 </span><span class="lineNoCov">              0 :         const_string cline( line );</span>
<span class="lineNum">     119 </span><span class="lineNoCov">              0 :         string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));</span>
<span class="lineNum">     120 </span>                :         
<span class="lineNum">     121 </span><span class="lineNoCov">              0 :         BOOST_CHECK_EQUAL( *tit, DP_SIG ); ++tit;</span>
<span class="lineNum">     122 </span><span class="lineNoCov">              0 :         return lexical_cast&lt;bool&gt;( *tit );</span>
<span class="lineNum">     123 </span>                :     }
<span class="lineNum">     124 </span>                :     else {
<span class="lineNum">     125 </span><span class="lineNoCov">              0 :         m_log_file &lt;&lt; DP_SIG &lt;&lt; CLMN_SEP &lt;&lt; std::boolalpha &lt;&lt; true &lt;&lt; LINE_SEP;</span>
<span class="lineNum">     126 </span>                :         
<span class="lineNum">     127 </span><span class="lineNoCov">              0 :         return true;</span>
<span class="lineNum">     128 </span>                :     }
<span class="lineNum">     129 </span>                : }
<span class="lineNum">     130 </span>                : 
<span class="lineNum">     131 </span>                : //____________________________________________________________________________//
<span class="lineNum">     132 </span>                :     
<span class="lineNum">     133 </span>                : unsigned
<span class="lineNum">     134 </span><span class="lineNoCov">              0 : expectations_logger::enter_scope( const_string, std::size_t, const_string scope_name )</span>
<span class="lineNum">     135 </span>                : {
<span class="lineNum">     136 </span><span class="lineNoCov">              0 :     if( m_test_or_log ) {</span>
<span class="lineNum">     137 </span><span class="lineNoCov">              0 :         std::string line;</span>
<span class="lineNum">     138 </span>                :         
<span class="lineNum">     139 </span><span class="lineNoCov">              0 :         std::getline( m_log_file, line, LINE_SEP );</span>
<span class="lineNum">     140 </span>                :         
<span class="lineNum">     141 </span><span class="lineNoCov">              0 :         const_string cline( line );</span>
<span class="lineNum">     142 </span><span class="lineNoCov">              0 :         string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));</span>
<span class="lineNum">     143 </span>                :         
<span class="lineNum">     144 </span><span class="lineNoCov">              0 :         BOOST_CHECK_EQUAL( *tit, SCOPE_SIG ); ++tit;</span>
<span class="lineNum">     145 </span><span class="lineNoCov">              0 :         BOOST_CHECK_EQUAL( *tit, scope_name );</span>
<span class="lineNum">     146 </span>                :     }
<span class="lineNum">     147 </span>                :     else {
<span class="lineNum">     148 </span><span class="lineNoCov">              0 :         m_log_file &lt;&lt; SCOPE_SIG &lt;&lt; CLMN_SEP &lt;&lt; scope_name &lt;&lt; LINE_SEP;</span>
<span class="lineNum">     149 </span>                :     }
<span class="lineNum">     150 </span>                :     
<span class="lineNum">     151 </span><span class="lineNoCov">              0 :     return 0;</span>
<span class="lineNum">     152 </span>                : }
<span class="lineNum">     153 </span>                :     
<span class="lineNum">     154 </span>                : //____________________________________________________________________________//
<span class="lineNum">     155 </span>                : 
<span class="lineNum">     156 </span>                : void
<span class="lineNum">     157 </span><span class="lineNoCov">              0 : expectations_logger::allocated( const_string, std::size_t, void*, std::size_t s )</span>
<span class="lineNum">     158 </span>                : {
<span class="lineNum">     159 </span><span class="lineNoCov">              0 :     if( m_test_or_log ) {</span>
<span class="lineNum">     160 </span><span class="lineNoCov">              0 :         std::string line;</span>
<span class="lineNum">     161 </span>                :         
<span class="lineNum">     162 </span><span class="lineNoCov">              0 :         std::getline( m_log_file, line, LINE_SEP );</span>
<span class="lineNum">     163 </span>                :         
<span class="lineNum">     164 </span><span class="lineNoCov">              0 :         const_string cline( line );</span>
<span class="lineNum">     165 </span><span class="lineNoCov">              0 :         string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));</span>
<span class="lineNum">     166 </span>                :         
<span class="lineNum">     167 </span><span class="lineNoCov">              0 :         BOOST_CHECK_EQUAL( *tit, ALLOC_SIG ); ++tit;</span>
<span class="lineNum">     168 </span><span class="lineNoCov">              0 :         BOOST_CHECK_EQUAL( lexical_cast&lt;std::size_t&gt;( *tit ), s );</span>
<span class="lineNum">     169 </span>                :     }
<span class="lineNum">     170 </span>                :     else {
<span class="lineNum">     171 </span><span class="lineNoCov">              0 :         m_log_file &lt;&lt; ALLOC_SIG &lt;&lt; CLMN_SEP &lt;&lt; s &lt;&lt; LINE_SEP;</span>
<span class="lineNum">     172 </span>                :     }
<span class="lineNum">     173 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     174 </span>                : 
<span class="lineNum">     175 </span>                : //____________________________________________________________________________//
<span class="lineNum">     176 </span>                : 
<span class="lineNum">     177 </span>                : void
<span class="lineNum">     178 </span><span class="lineNoCov">              0 : expectations_logger::data_flow( const_string d )</span>
<span class="lineNum">     179 </span>                : {
<span class="lineNum">     180 </span><span class="lineNoCov">              0 :     if( m_test_or_log ) {</span>
<span class="lineNum">     181 </span><span class="lineNoCov">              0 :         std::string line;</span>
<span class="lineNum">     182 </span>                :         
<span class="lineNum">     183 </span><span class="lineNoCov">              0 :         std::getline( m_log_file, line, LINE_SEP );</span>
<span class="lineNum">     184 </span>                :         
<span class="lineNum">     185 </span><span class="lineNoCov">              0 :         const_string cline( line );</span>
<span class="lineNum">     186 </span><span class="lineNoCov">              0 :         string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));</span>
<span class="lineNum">     187 </span>                :         
<span class="lineNum">     188 </span><span class="lineNoCov">              0 :         BOOST_CHECK_EQUAL( *tit, DATA_SIG ); ++tit;</span>
<span class="lineNum">     189 </span><span class="lineNoCov">              0 :         BOOST_CHECK_EQUAL( *tit, d );</span>
<span class="lineNum">     190 </span>                :     }
<span class="lineNum">     191 </span>                :     else {
<span class="lineNum">     192 </span><span class="lineNoCov">              0 :         m_log_file &lt;&lt; DATA_SIG &lt;&lt; CLMN_SEP &lt;&lt; d &lt;&lt; LINE_SEP;</span>
<span class="lineNum">     193 </span>                :     }
<span class="lineNum">     194 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     195 </span>                : 
<span class="lineNum">     196 </span>                : //____________________________________________________________________________//
<span class="lineNum">     197 </span>                : 
<span class="lineNum">     198 </span>                : std::string
<span class="lineNum">     199 </span><span class="lineNoCov">              0 : expectations_logger::return_value( const_string default_value )</span>
<span class="lineNum">     200 </span>                : {
<span class="lineNum">     201 </span><span class="lineNoCov">              0 :     if( m_test_or_log ) {</span>
<span class="lineNum">     202 </span><span class="lineNoCov">              0 :         std::string line;</span>
<span class="lineNum">     203 </span>                :         
<span class="lineNum">     204 </span><span class="lineNoCov">              0 :         std::getline( m_log_file, line, LINE_SEP );</span>
<span class="lineNum">     205 </span>                :         
<span class="lineNum">     206 </span><span class="lineNoCov">              0 :         const_string cline( line );</span>
<span class="lineNum">     207 </span><span class="lineNoCov">              0 :         string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));</span>
<span class="lineNum">     208 </span>                :         
<span class="lineNum">     209 </span><span class="lineNoCov">              0 :         BOOST_CHECK_EQUAL( *tit, RETURN_SIG ); ++tit;</span>
<span class="lineNum">     210 </span>                :         
<span class="lineNum">     211 </span><span class="lineNoCov">              0 :         return std::string( tit-&gt;begin(), tit-&gt;size() );</span>
<span class="lineNum">     212 </span>                :     }
<span class="lineNum">     213 </span>                :     else {
<span class="lineNum">     214 </span><span class="lineNoCov">              0 :         m_log_file &lt;&lt; RETURN_SIG &lt;&lt; CLMN_SEP &lt;&lt; default_value &lt;&lt; LINE_SEP;</span>
<span class="lineNum">     215 </span>                :                                  
<span class="lineNum">     216 </span><span class="lineNoCov">              0 :         return std::string();</span>
<span class="lineNum">     217 </span>                :     }
<span class="lineNum">     218 </span>                : }
<span class="lineNum">     219 </span>                : 
<span class="lineNum">     220 </span>                : //____________________________________________________________________________//
<span class="lineNum">     221 </span>                :     
<span class="lineNum">     222 </span>                : // ************************************************************************** //
<span class="lineNum">     223 </span>                : // **************           logged expectations test           ************** //
<span class="lineNum">     224 </span>                : // ************************************************************************** //
<span class="lineNum">     225 </span>                : 
<span class="lineNum">     226 </span>                : void BOOST_TEST_DECL
<span class="lineNum">     227 </span><span class="lineNoCov">              0 : logged_expectations( callback0&lt;&gt; const&amp; F, const_string log_file_name, bool test_or_log )</span>
<span class="lineNum">     228 </span>                : {
<span class="lineNum">     229 </span><span class="lineNoCov">              0 :     expectations_logger el( log_file_name, test_or_log );</span>
<span class="lineNum">     230 </span>                : 
<span class="lineNum">     231 </span><span class="lineNoCov">              0 :     F();</span>
<span class="lineNum">     232 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     233 </span>                : 
<span class="lineNum">     234 </span>                : //____________________________________________________________________________//
<span class="lineNum">     235 </span>                : 
<span class="lineNum">     236 </span>                : }  // namespace itest
<span class="lineNum">     237 </span>                : 
<span class="lineNum">     238 </span>                : } // namespace boost
<span class="lineNum">     239 </span>                : 
<span class="lineNum">     240 </span>                : //____________________________________________________________________________//
<span class="lineNum">     241 </span>                : 
<span class="lineNum">     242 </span>                : #include &lt;boost/test/detail/enable_warnings.hpp&gt;
<span class="lineNum">     243 </span>                : 
<span class="lineNum">     244 </span>                : #endif // not ancient compiler
<span class="lineNum">     245 </span>                : 
<span class="lineNum">     246 </span>                : #endif // BOOST_TEST_LOGGED_EXPECTATIONS_IPP_120905GER
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
